package com.xiaoke.service.impl;

import com.xiaoke.entity.User;
import com.xiaoke.mapper.UserMapper;
import com.xiaoke.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;
import java.util.List;
import java.util.Map;

@Service
@Transactional
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;

    @Override
    public User findByToken(String token){
        return userMapper.findByToken(token);
    }

    @Override
    public List<User> findByParams(@RequestBody Map<String, Object> map) {
        return userMapper.findByParams(map);
    }

    @Override
    @Transactional(readOnly = false)
    public void update(@RequestBody User user) {
        userMapper.updateByPrimaryKeySelective(user);
    }

    @Override
    @Transactional(readOnly = false)
    public void insert(@RequestBody  User user) {
        userMapper.insert(user);
    }
}
